<%@ page language="java" contentType ="text/html; charset=utf-8" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";
	request.setAttribute("ctx", basePath);
 
%>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!--   <link rel="stylesheet" href="//res.layui.com/layui/dist/css/layui.css"  media="all"> -->
    <link rel="stylesheet" href="${ctx}plugins/layui/css/layui.css" media="all">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
  <style type="text/css">
/*   .layui-body{overflow-y: scroll;} */
  body{overflow-y: scroll;}
  </style>
</head>
<body> 
 
<div class="demoTable">
  任务ID：
  <div class="layui-inline">
    <input class="layui-input" name="taskId" id="taskId" autocomplete="off">
  </div>
  任务名称：
  <div class="layui-inline">
    <input class="layui-input" name="taskName" id="taskName" autocomplete="off">
  </div>
  创建时间
  <div class="layui-inline">
    <input class="layui-input" name="start" id="start" autocomplete="off" readonly="readonly">
  </div>
  -
  <div class="layui-inline">
    <input class="layui-input" name="end" id="end" autocomplete="off" readonly="readonly">
  </div>
  <button class="layui-btn" data-type="reload">搜索</button>
</div>
 
<table class="layui-hide" id="LAY_table_task_log" lay-filter="tasklog"></table> 
               
          
<script src="${ctx}plugins/layui/layui.js"></script>
<script src="${ctx}build/js/date+.js"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script type="text/html" id="barDemo">
	<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
  <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script type="text/html" id="toStartTime">
{{layui.util.toDateString(d.startTime, 'yyyy-MM-dd HH:mm:ss')}}
</script>
<script type="text/html" id="toEndTime">
{{layui.util.toDateString(d.endTime, 'yyyy-MM-dd HH:mm:ss')}}
</script>
<script>
layui.use(['table', 'laydate'], function(){
  var table = layui.table
  	,$=layui.$
  	,form = layui.form
  	,laydate = layui.laydate;
  
  laydate.render({
	  elem: '#start'
	  ,format: 'yyyy-MM-dd'
	});
  laydate.render({
	  elem: '#end'
	  ,format: 'yyyy-MM-dd'
	});
  //方法级渲染
  table.render({
    elem: '#LAY_table_task_log'
    ,url: '${ctx}timedtasklog?method=queryPage'
    ,cellMinWidth: 10 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
    ,cols: [[
      {field:'taskId', title:'任务ID', width:80}
      ,{field:'taskName', title: '任务名称', width:160}
      ,{field:'taskGroup', title: '任务组', width:160}
      ,{field:'startTime', title: '开始', templet: '#toStartTime', width:200}
      ,{field:'endTime', title: '结束',templet: '#toEndTime', width:200}
      ,{field:'exeTimeLong', title: '耗时', width:90}
      ,{field:'exeResult', title: '结果',width:90}
    ]]
    ,id: 'testReload'
    ,page: true
  });
  
//   //监听工具条
//   table.on('tool(tasklog)', function(obj){
//     var data = obj.data;
//     if(obj.event === 'detail'){
//       layer.msg('ID：'+ data.id + ' 的查看操作');
//     } else if(obj.event === 'del'){
//       layer.confirm('真的删除行么', function(index){
//         obj.del();
//         layer.close(index);
//       });
//     } else if(obj.event === 'edit'){
//       layer.alert('编辑行：<br>'+ JSON.stringify(data))
//     }
//   });
  
  var active = {
    reload: function(){
      var taskId = $('#taskId');
      var taskName=$('#taskName');
      var taskGroup = $('#taskGroup');
      var start = $('#start');
      var end = $('#end');
      
      //执行重载
      table.reload('testReload', {
        page: {
          curr: 1 //重新从第 1 页开始
        }
        ,where: {
          key: {
            id: taskId.val(),
            taskName: taskName.val(),
            taskGroup: taskGroup.val(),
            start: start.val(),
            end: end.val()
          }
        }
      });
    }
  };
  
  $('.demoTable .layui-btn').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });
});
</script>

</body>
</html>